var longestCommonPrefix = function(strs){
    if(strs.length == 0){
        return '';
    }
    var commonPrefix = strs[0];
    for(var i = 1;i < strs.length ;i++){
        commonPrefix = findCommon(commonPrefix , strs[i])
    }
    return commonPrefix

    function findCommon (a,b){
        var i = 0;
        while(i < a.length && i < b.length && a.charAt(i) == b.charAt(i)){
            i++
        }
        return i > 0 ?  a.substring(0,i) : '';
    }
}
